﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using FileSystem.Services.IServices;
using FileSystem.Services.Realization;
using Moq;

namespace FileSystem.UnitTest.Helpers {
    /// <summary>
    /// 物理磁盘块存储帮助类
    /// </summary>
    public class PhysicalDiskBlockStorageHelper {
        /// <summary>
        /// 获得已初始化的物理磁盘块存储
        /// </summary>
        public static async Task<PhysicalDiskBlockStorage>
            GetInitializedPhysicalDiskBlockStorageAsync() {
            var physicalDiskBlockStorage = new PhysicalDiskBlockStorage(
                new Mock<IPreferenceStorage>().Object);
            await physicalDiskBlockStorage.InitializeAsync();
            return physicalDiskBlockStorage;
        }

        /// <summary>
        /// 删除物理磁盘块数据库文件
        /// </summary>
        public static async Task RemoveDatabaseFile() {
            var physicalDiskBlockStorage = new PhysicalDiskBlockStorage(null);
            await physicalDiskBlockStorage.CloseAsync();
            File.Delete(PhysicalDiskBlockStorage.DbPath);
        }
    }
}